package com.fengchao.dao;

import com.fengchao.model.UsrPersonalMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by http://my.oschina.net/wangnian on 2016/7/21.
 */
@Mapper
public interface UsrPersonalMessageMapper {

    /**
     * 查询所有系统的推送（推送所有）
     *
     * @return
     */
    @Select("select * from usr_personal_message where is_need_push=1 and is_push=0 and orgin_message_id is not null  GROUP BY orgin_message_id ")
    List<UsrPersonalMessage> findBySys();


    /**
     * 根据orgin_message_id修改为已推送
     *
     * @param orginMessageId
     * @return
     */
    @Select("update usr_personal_message set is_push=1  where orgin_message_id=#{orginMessageId}")
    Integer updateIsPushByOrginMessageId(Integer orginMessageId);

    /**
     * 根据id修改为已推送
     *
     * @param id
     * @return
     */
    @Select("update usr_personal_message set is_push=1  where id=#{id}")
    Integer updateIsPushById(Integer id);
}
